package com.monolithiot.sso.common.entity;

import com.monolithiot.sso.common.context.Constants;
import com.monolithiot.sso.common.data.Terminable;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

/**
 * 2018/12/22 Create by 郭文梁
 * DeviceAuthorization
 * 设备授权实体类
 *
 * @author 郭文梁
 * @date 2018/12/22
 */
@Data
@Table(name = "tb_device_authorization")
public class DeviceAuthorization implements Terminable {
    /**
     * ID
     * id                 INT(10)      NOT NULL AUTO_INCREMENT,
     */
    @Id
    @GeneratedValue(generator = Constants.SQL.GENERATOR_JDBC)
    @Column(name = "id", length = 10, nullable = false)
    private Integer id;
    /**
     * user_id            INT(10)      NOT NULL
     * COMMENT '被授权用户ID',
     */
    @Column(name = "user_id", length = 10, nullable = false)
    private Integer userId;
    /**
     * 被授权用户
     */
    private User user;
    /**
     * device_type_id     INT(10)      NOT NULL
     * COMMENT '设备类型ID',
     */
    @Column(name = "device_type_id", length = 10, nullable = false)
    private Integer deviceTypeId;
    /**
     * 设备类型对象
     */
    private DeviceType deviceType;
    /**
     * 设备名称
     */
    @Column(name = "device_name", length = 100)
    private String deviceName;
    /**
     * serial_number VARCHAR(255) NOT NULL
     * COMMENT '设备唯一识别码';
     */
    @Column(name = "serial_number", nullable = false)
    private String serialNumber;
    /**
     * token              VARCHAR(255) NOT NULL
     * COMMENT '令牌',
     */
    @Column(name = "token", nullable = false)
    private String token;
    /**
     * create_time        DATETIME     NOT NULL
     * COMMENT '创建时间',
     */
    @Column(name = "create_time", nullable = false)
    private Date createTime;
    /**
     * last_activity_time DATETIME     NOT NULL
     * COMMENT '最后一次活动时间',
     */
    @Column(name = "last_activity_time", nullable = false)
    private Date lastActivityTime;
    /**
     * expire_in          INT(10)       NOT NULL
     * COMMENT '有效时间',
     */
    @Column(name = "expire_in", length = 10, nullable = false)
    private Integer expireIn;
}
